package cn.edu.scau.cmi.chenjunlin.mterProgramming.Experiment4.Example2;

import java.util.ArrayList;
import java.util.Iterator;


public class Composite1 extends WorldOrganization1{
	private ArrayList<WorldOrganization1> countryList;
	private String saying = "";
	public Composite1() {countryList = new ArrayList<WorldOrganization1>();}
	public void add(WorldOrganization1 country) {
		if(country!=null) {countryList.add(country);}
	}
	public void remove(WorldOrganization1 country) {
		if(country!=null) {countryList.remove(country);}
	}
	public Iterator<WorldOrganization1> elements(){
		return countryList.iterator();
	}
	public String say() {
		int len = countryList.size();
		for(int i = 0; i < len; i++) {
			WorldOrganization1 ctry = countryList.get(i);
			saying = saying + ctry.say();
		}
		return saying;
	}
	public int getSize() {return countryList.size();}
}
